]> dgit.raspbian.org Git - gnome-shell.git/commitdiff
iconGrid: Bail out of getRowPadding early if we'll return 0
authorJonas Dreßler <verdre@v0yd.nl>
Wed, 24 Feb 2021 11:06:19 +0000 (12:06 +0100)
committerMarge Bot <marge-bot@gnome.org>
Wed, 3 Mar 2021 17:59:15 +0000 (17:59 +0000)
This gets our time spent in vfunc_allocate() down again by ~0.1 ms from
1.4 ms to 1.3 ms.

Part-of: <https://gitlab.gnome.org/GNOME/gnome-shell/-/merge_requests/1713>

js/ui/iconGrid.js

index 27ffd733e0891be8ccde83f2d114c5b3c4782da5..8f6b547019bb8bf5e9b64812c6d8ce982a4b46db 100644 (file)
@@ -663,6 +663,10 @@ var IconGridLayout = GObject.registerClass({
     }
 
     _getRowPadding(items, itemIndex, childSize, spacing) {
+        if (this.lastRowAlign === Clutter.ActorAlign.START ||
+            this.lastRowAlign === Clutter.ActorAlign.FILL)
+            return 0;
+
         const nRows = Math.ceil(items.length / this.columnsPerPage);
 
         let rowAlign = 0;
@@ -682,18 +686,13 @@ var IconGridLayout = GObject.registerClass({
             Clutter.get_default_text_direction() === Clutter.TextDirection.RTL;
 
         switch (this.lastRowAlign) {
-        case Clutter.ActorAlign.START:
-            rowAlign = 0;
-            break;
         case Clutter.ActorAlign.CENTER:
             rowAlign = availableWidth / 2;
             break;
         case Clutter.ActorAlign.END:
             rowAlign = availableWidth;
             break;
-        case Clutter.ActorAlign.FILL:
-            rowAlign = 0;
-            break;
+        // START and FILL align are handled at the beginning of the function
         }
 
         return isRtl ? rowAlign * -1 : rowAlign;